package com.miyake.loveviewweb.server.meta;

//@javax.annotation.Generated(value = { "slim3-gen", "@VERSION@" }, date = "2012-07-11 14:41:10")
/** */
public final class PluginModelMeta extends org.slim3.datastore.ModelMeta<com.miyake.loveviewweb.shared.model.PluginModel> {

    /** */
    public final org.slim3.datastore.StringAttributeMeta<com.miyake.loveviewweb.shared.model.PluginModel> category = new org.slim3.datastore.StringAttributeMeta<com.miyake.loveviewweb.shared.model.PluginModel>(this, "category", "category");

    /** */
    public final org.slim3.datastore.StringAttributeMeta<com.miyake.loveviewweb.shared.model.PluginModel> companyUrl = new org.slim3.datastore.StringAttributeMeta<com.miyake.loveviewweb.shared.model.PluginModel>(this, "companyUrl", "companyUrl");

    /** */
    public final org.slim3.datastore.CoreAttributeMeta<com.miyake.loveviewweb.shared.model.PluginModel, com.google.appengine.api.datastore.Key> creator = new org.slim3.datastore.CoreAttributeMeta<com.miyake.loveviewweb.shared.model.PluginModel, com.google.appengine.api.datastore.Key>(this, "creator", "creator", com.google.appengine.api.datastore.Key.class);

    /** */
    public final org.slim3.datastore.StringAttributeMeta<com.miyake.loveviewweb.shared.model.PluginModel> description = new org.slim3.datastore.StringAttributeMeta<com.miyake.loveviewweb.shared.model.PluginModel>(this, "description", "description");

    /** */
    public final org.slim3.datastore.StringCollectionAttributeMeta<com.miyake.loveviewweb.shared.model.PluginModel, java.util.List<java.lang.String>> headers = new org.slim3.datastore.StringCollectionAttributeMeta<com.miyake.loveviewweb.shared.model.PluginModel, java.util.List<java.lang.String>>(this, "headers", "headers", java.util.List.class);

    /** */
    public final org.slim3.datastore.CoreAttributeMeta<com.miyake.loveviewweb.shared.model.PluginModel, com.google.appengine.api.datastore.Key> key = new org.slim3.datastore.CoreAttributeMeta<com.miyake.loveviewweb.shared.model.PluginModel, com.google.appengine.api.datastore.Key>(this, "__key__", "key", com.google.appengine.api.datastore.Key.class);

    /** */
    public final org.slim3.datastore.StringAttributeMeta<com.miyake.loveviewweb.shared.model.PluginModel> license = new org.slim3.datastore.StringAttributeMeta<com.miyake.loveviewweb.shared.model.PluginModel>(this, "license", "license");

    /** */
    public final org.slim3.datastore.StringAttributeMeta<com.miyake.loveviewweb.shared.model.PluginModel> provider = new org.slim3.datastore.StringAttributeMeta<com.miyake.loveviewweb.shared.model.PluginModel>(this, "provider", "provider");

    /** */
    public final org.slim3.datastore.StringAttributeMeta<com.miyake.loveviewweb.shared.model.PluginModel> serviceName = new org.slim3.datastore.StringAttributeMeta<com.miyake.loveviewweb.shared.model.PluginModel>(this, "serviceName", "serviceName");

    /** */
    public final org.slim3.datastore.StringAttributeMeta<com.miyake.loveviewweb.shared.model.PluginModel> serviceType = new org.slim3.datastore.StringAttributeMeta<com.miyake.loveviewweb.shared.model.PluginModel>(this, "serviceType", "serviceType");

    /** */
    public final org.slim3.datastore.StringAttributeMeta<com.miyake.loveviewweb.shared.model.PluginModel> serviceUrl = new org.slim3.datastore.StringAttributeMeta<com.miyake.loveviewweb.shared.model.PluginModel>(this, "serviceUrl", "serviceUrl");

    /** */
    public final org.slim3.datastore.StringAttributeMeta<com.miyake.loveviewweb.shared.model.PluginModel> serviceVersion = new org.slim3.datastore.StringAttributeMeta<com.miyake.loveviewweb.shared.model.PluginModel>(this, "serviceVersion", "serviceVersion");

    /** */
    public final org.slim3.datastore.StringAttributeMeta<com.miyake.loveviewweb.shared.model.PluginModel> tags = new org.slim3.datastore.StringAttributeMeta<com.miyake.loveviewweb.shared.model.PluginModel>(this, "tags", "tags");

    /** */
    public final org.slim3.datastore.CoreAttributeMeta<com.miyake.loveviewweb.shared.model.PluginModel, java.lang.Long> version = new org.slim3.datastore.CoreAttributeMeta<com.miyake.loveviewweb.shared.model.PluginModel, java.lang.Long>(this, "version", "version", java.lang.Long.class);

    private static final PluginModelMeta slim3_singleton = new PluginModelMeta();

    /**
     * @return the singleton
     */
    public static PluginModelMeta get() {
       return slim3_singleton;
    }

    /** */
    public PluginModelMeta() {
        super("PluginModel", com.miyake.loveviewweb.shared.model.PluginModel.class);
    }

    @Override
    public com.miyake.loveviewweb.shared.model.PluginModel entityToModel(com.google.appengine.api.datastore.Entity entity) {
        com.miyake.loveviewweb.shared.model.PluginModel model = new com.miyake.loveviewweb.shared.model.PluginModel();
        model.setCategory((java.lang.String) entity.getProperty("category"));
        model.setCompanyUrl((java.lang.String) entity.getProperty("companyUrl"));
        model.setCreator((com.google.appengine.api.datastore.Key) entity.getProperty("creator"));
        model.setDescription((java.lang.String) entity.getProperty("description"));
        model.setHeaders(toList(java.lang.String.class, entity.getProperty("headers")));
        model.setKey(entity.getKey());
        model.setLicense((java.lang.String) entity.getProperty("license"));
        model.setProvider((java.lang.String) entity.getProperty("provider"));
        model.setServiceName((java.lang.String) entity.getProperty("serviceName"));
        model.setServiceType((java.lang.String) entity.getProperty("serviceType"));
        model.setServiceUrl((java.lang.String) entity.getProperty("serviceUrl"));
        model.setServiceVersion((java.lang.String) entity.getProperty("serviceVersion"));
        model.setTags((java.lang.String) entity.getProperty("tags"));
        model.setVersion((java.lang.Long) entity.getProperty("version"));
        return model;
    }

    @Override
    public com.google.appengine.api.datastore.Entity modelToEntity(java.lang.Object model) {
        com.miyake.loveviewweb.shared.model.PluginModel m = (com.miyake.loveviewweb.shared.model.PluginModel) model;
        com.google.appengine.api.datastore.Entity entity = null;
        if (m.getKey() != null) {
            entity = new com.google.appengine.api.datastore.Entity(m.getKey());
        } else {
            entity = new com.google.appengine.api.datastore.Entity(kind);
        }
        entity.setProperty("category", m.getCategory());
        entity.setProperty("companyUrl", m.getCompanyUrl());
        entity.setProperty("creator", m.getCreator());
        entity.setProperty("description", m.getDescription());
        entity.setProperty("headers", m.getHeaders());
        entity.setProperty("license", m.getLicense());
        entity.setProperty("provider", m.getProvider());
        entity.setProperty("serviceName", m.getServiceName());
        entity.setProperty("serviceType", m.getServiceType());
        entity.setProperty("serviceUrl", m.getServiceUrl());
        entity.setProperty("serviceVersion", m.getServiceVersion());
        entity.setProperty("tags", m.getTags());
        entity.setProperty("version", m.getVersion());
        entity.setProperty("slim3.schemaVersion", 1);
        return entity;
    }

    @Override
    protected com.google.appengine.api.datastore.Key getKey(Object model) {
        com.miyake.loveviewweb.shared.model.PluginModel m = (com.miyake.loveviewweb.shared.model.PluginModel) model;
        return m.getKey();
    }

    @Override
    protected void setKey(Object model, com.google.appengine.api.datastore.Key key) {
        validateKey(key);
        com.miyake.loveviewweb.shared.model.PluginModel m = (com.miyake.loveviewweb.shared.model.PluginModel) model;
        m.setKey(key);
    }

    @Override
    protected long getVersion(Object model) {
        com.miyake.loveviewweb.shared.model.PluginModel m = (com.miyake.loveviewweb.shared.model.PluginModel) model;
        return m.getVersion() != null ? m.getVersion().longValue() : 0L;
    }

    @Override
    protected void assignKeyToModelRefIfNecessary(com.google.appengine.api.datastore.AsyncDatastoreService ds, java.lang.Object model) {
    }

    @Override
    protected void incrementVersion(Object model) {
        com.miyake.loveviewweb.shared.model.PluginModel m = (com.miyake.loveviewweb.shared.model.PluginModel) model;
        long version = m.getVersion() != null ? m.getVersion().longValue() : 0L;
        m.setVersion(Long.valueOf(version + 1L));
    }

    @Override
    protected void prePut(Object model) {
    }

    @Override
    protected void postGet(Object model) {
    }

    @Override
    public String getSchemaVersionName() {
        return "slim3.schemaVersion";
    }

    @Override
    public String getClassHierarchyListName() {
        return "slim3.classHierarchyList";
    }

    @Override
    protected boolean isCipherProperty(String propertyName) {
        return false;
    }

    @Override
    protected void modelToJson(org.slim3.datastore.json.JsonWriter writer, java.lang.Object model, int maxDepth, int currentDepth) {
        com.miyake.loveviewweb.shared.model.PluginModel m = (com.miyake.loveviewweb.shared.model.PluginModel) model;
        writer.beginObject();
        org.slim3.datastore.json.Default encoder0 = new org.slim3.datastore.json.Default();
        if(m.getCategory() != null){
            writer.setNextPropertyName("category");
            encoder0.encode(writer, m.getCategory());
        }
        if(m.getCompanyUrl() != null){
            writer.setNextPropertyName("companyUrl");
            encoder0.encode(writer, m.getCompanyUrl());
        }
        if(m.getCreator() != null){
            writer.setNextPropertyName("creator");
            encoder0.encode(writer, m.getCreator());
        }
        if(m.getDescription() != null){
            writer.setNextPropertyName("description");
            encoder0.encode(writer, m.getDescription());
        }
        if(m.getHeaders() != null){
            writer.setNextPropertyName("headers");
            writer.beginArray();
            for(java.lang.String v : m.getHeaders()){
                encoder0.encode(writer, v);
            }
            writer.endArray();
        }
        if(m.getKey() != null){
            writer.setNextPropertyName("key");
            encoder0.encode(writer, m.getKey());
        }
        if(m.getLicense() != null){
            writer.setNextPropertyName("license");
            encoder0.encode(writer, m.getLicense());
        }
        if(m.getProvider() != null){
            writer.setNextPropertyName("provider");
            encoder0.encode(writer, m.getProvider());
        }
        if(m.getServiceName() != null){
            writer.setNextPropertyName("serviceName");
            encoder0.encode(writer, m.getServiceName());
        }
        if(m.getServiceType() != null){
            writer.setNextPropertyName("serviceType");
            encoder0.encode(writer, m.getServiceType());
        }
        if(m.getServiceUrl() != null){
            writer.setNextPropertyName("serviceUrl");
            encoder0.encode(writer, m.getServiceUrl());
        }
        if(m.getServiceVersion() != null){
            writer.setNextPropertyName("serviceVersion");
            encoder0.encode(writer, m.getServiceVersion());
        }
        if(m.getTags() != null){
            writer.setNextPropertyName("tags");
            encoder0.encode(writer, m.getTags());
        }
        if(m.getValues() != null){
            writer.setNextPropertyName("values");
            // com.miyake.loveviewweb.shared.model.ValueModel is not supported.
        }
        if(m.getVersion() != null){
            writer.setNextPropertyName("version");
            encoder0.encode(writer, m.getVersion());
        }
        writer.endObject();
    }

    @Override
    protected com.miyake.loveviewweb.shared.model.PluginModel jsonToModel(org.slim3.datastore.json.JsonRootReader rootReader, int maxDepth, int currentDepth) {
        com.miyake.loveviewweb.shared.model.PluginModel m = new com.miyake.loveviewweb.shared.model.PluginModel();
        org.slim3.datastore.json.JsonReader reader = null;
        org.slim3.datastore.json.Default decoder0 = new org.slim3.datastore.json.Default();
        reader = rootReader.newObjectReader("category");
        m.setCategory(decoder0.decode(reader, m.getCategory()));
        reader = rootReader.newObjectReader("companyUrl");
        m.setCompanyUrl(decoder0.decode(reader, m.getCompanyUrl()));
        reader = rootReader.newObjectReader("creator");
        m.setCreator(decoder0.decode(reader, m.getCreator()));
        reader = rootReader.newObjectReader("description");
        m.setDescription(decoder0.decode(reader, m.getDescription()));
        reader = rootReader.newObjectReader("headers");
        {
            java.util.ArrayList<java.lang.String> elements = new java.util.ArrayList<java.lang.String>();
            org.slim3.datastore.json.JsonArrayReader r = rootReader.newArrayReader("headers");
            if(r != null){
                reader = r;
                int n = r.length();
                for(int i = 0; i < n; i++){
                    r.setIndex(i);
                    java.lang.String v = decoder0.decode(reader, (java.lang.String)null)                    ;
                    if(v != null){
                        elements.add(v);
                    }
                }
                m.setHeaders(elements);
            }
        }
        reader = rootReader.newObjectReader("key");
        m.setKey(decoder0.decode(reader, m.getKey()));
        reader = rootReader.newObjectReader("license");
        m.setLicense(decoder0.decode(reader, m.getLicense()));
        reader = rootReader.newObjectReader("provider");
        m.setProvider(decoder0.decode(reader, m.getProvider()));
        reader = rootReader.newObjectReader("serviceName");
        m.setServiceName(decoder0.decode(reader, m.getServiceName()));
        reader = rootReader.newObjectReader("serviceType");
        m.setServiceType(decoder0.decode(reader, m.getServiceType()));
        reader = rootReader.newObjectReader("serviceUrl");
        m.setServiceUrl(decoder0.decode(reader, m.getServiceUrl()));
        reader = rootReader.newObjectReader("serviceVersion");
        m.setServiceVersion(decoder0.decode(reader, m.getServiceVersion()));
        reader = rootReader.newObjectReader("tags");
        m.setTags(decoder0.decode(reader, m.getTags()));
        reader = rootReader.newObjectReader("values");
        reader = rootReader.newObjectReader("version");
        m.setVersion(decoder0.decode(reader, m.getVersion()));
        return m;
    }
}